'use strict';


const { success, commonErr } = require('../extend/helper');
const BaseController = require('./base');
const { idcardRule, educationRule } = require('../validator/verify');
const utils = require("../extend/dun-utils");

class VerifyController extends BaseController {

    /**
     * 学历验证 - 后台人工审核
     * 学历认证方式:1=国内学信网在线认证,2=毕业证/学位证书认证,3=毕业证、学位证书编号,4=港澳台或海外学历认证
     * 2-毕业证/学位证书认证：@param: 学校，学历，毕业证图片
     * 1，，3，4提供证书编号
     */
    async artificial() {
        const data = this.ctx.request.body;
        const errors = this.app.validator.validate(educationRule, data);
        errors && this.ctx.helper.commonErr('参数错误', { beans: errors });
        const userId = await this.userId();
        console.log(userId);
        await this.service.identity.education(userId, data);
        success();
    }

   /**
    * 实名验证
    */
    async idcard() {
        const data = this.ctx.request.body;
        const errors = this.app.validator.validate(idcardRule, data);
        errors && this.ctx.helper.commonErr('参数错误', { beans: errors });
        const userId = await this.userId();
        await this.service.identity.checkIdCard(userId, data.username, data.card_no);
     
    }

}

module.exports = VerifyController;